//index.js
//获取应用实例
const app = getApp()

Page({
  data: {
    isPlayingMusic: false
  },
  //事件处理函数
  bgm: null,
  music_url: 'https://link.hhtjim.com/163/5145730.mp3',
  music_coverImgUrl:'http://p1.music.126.net/iRkt6pHKwcQKDch6-VNXZQ==/1751522023059530.jpg?param=130y130',
  onReady: function() {
    this.bgm = wx.getBackgroundAudioManager()
    this.bgm.title = 'I Love You'
    this.bgm.epname = 'wedding'
    this.bgm.singer = '王若琳'
    this.bgm.coverImgUrl = this.music_coverImgUrl
    this.bgm.onCanplay( ()=> {
      this.bgm.pause()
    })
    this.bgm.src = this.music_url
  },
  play: function(e) {
    if (this.data.isPlayingMusic) {
      this.bgm.pause()
    } else {
      this.bgm.play()
    }
    this.setData({
      isPlayingMusic: !this.data.isPlayingMusic
    })
  },
  callGroom: function() {
    wx.makePhoneCall({
      phoneNumber: '123',
    })
  },
  callBride: function() {
    wx.makePhoneCall({
      phoneNumber: '456',
    })
  }
})
